#!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2016-2019, Intel Corporation

#
# src/test/blk_pool/TEST30 -- unit test for pmemblk_open
#

. ../unittest/unittest.sh

require_test_type medium

setup
umask 0

#
# TEST30 existing file, file size >= min required size, bsize == 300
#        (pool set with replica section)
#
expect_normal_exit ./blk_pool$EXESUFFIX c $DIR/testfile1 300 20 0640

cp $DIR/testfile1 $DIR/testfile2

$PMEMSPOIL $DIR/testfile1 pool_hdr.uuid=1111111111111111 \
	pool_hdr.next_part_uuid=1111111111111111 \
	pool_hdr.prev_part_uuid=1111111111111111 \
	pool_hdr.next_repl_uuid=2222222222222222 \
	pool_hdr.prev_repl_uuid=2222222222222222 \
	"pool_hdr.f:checksum_gen"

$PMEMSPOIL $DIR/testfile2 pool_hdr.uuid=2222222222222222 \
	pool_hdr.next_part_uuid=2222222222222222 \
	pool_hdr.prev_part_uuid=2222222222222222 \
	pool_hdr.next_repl_uuid=1111111111111111 \
	pool_hdr.prev_repl_uuid=1111111111111111 \
	"pool_hdr.f:checksum_gen"

create_poolset $DIR/testset 20M:$DIR/testfile1 R 20M:$DIR/testfile2

expect_normal_exit ./blk_pool$EXESUFFIX o $DIR/testset 300

check

pass
